import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MemberVO, MemberForm, MemberQuery } from '@/api/member/types';

/**
 * 查询会员用户列表
 * @param query
 * @returns {*}
 */
export const getMemberList = (query?: MemberQuery): AxiosPromise<MemberVO[]> => {
  return request({
    url: '/member/member/list',
    method: 'get',
    params: query
  });
};

/**
 * 获取会员用户详细信息
 * @param id
 */
export const getMemberDetail = (id: string | number): AxiosPromise<MemberVO> => {
  return request({
    url: '/member/member/' + id,
    method: 'get'
  });
};

/**
 * 新增会员用户
 * @param data
 */
export const addMember = (data: MemberForm) => {
  return request({
    url: '/member/member',
    method: 'post',
    data: data
  });
};

/**
 * 修改会员用户
 * @param data
 */
export const updateMember = (data: MemberForm) => {
  return request({
    url: '/member/member',
    method: 'put',
    data: data
  });
};

/**
 * 删除会员用户
 * @param id
 */
export const deleteMember = (ids: string | number | Array<string | number>) => {
  return request({
    url: '/member/member/' + ids,
    method: 'delete'
  });
};
